var express = require('express');
var http = require('http');
var router = express.Router();
var fs = require('fs');
fs.readdir('./',(err,files) => {
	console.log(files);
});
router.get('/file',function(req,res){
	console.log(req.query);
	fs.readdir('node_modules',(err,files) => {
		//console.log(files);	
		fs.readFile('frontend/'+files[0],'utf8',(err,data) => {
			//console.log(data);
			res.send(files);
		})
	});
});
router.post('/file/:name',function(req,res){
	console.log(req.body);
	console.log(req.params);
	fs.readdir('frontend',(err,files) => {
		//console.log(files);	
		fs.readFile('frontend/'+req.params.name,'utf8',(err,data) => {
			console.log(data);
			res.send(data);
		})
	});
});
module.exports = router;